<template>
   <div>
    <MyHeader title="购物车案例" bgc='pink'></MyHeader>
    <div class="main">
      <!-- 利用v-for遍历数据 -->
      <MyGoods v-for='item in list' :key='item.id' :good='item'></MyGoods>
    </div>
    <MyFooter :list='list'></MyFooter>
  </div>
</template>

<script>
import MyHeader from './components/MyHeader'
import MyGoods from './components/MyGoods'
import MyFooter from './components/MyFooter'
export default {
  data () {
    return {
      list:[]
    }
  },
  created () {
    this.$axios({
      url:"/api/cart",
    }).then(res=>{
      this.list=res.data.list
    }).catch(err=>{//捕获错误
      console.log(err);
    })
  },
  components: {
    MyHeader,
    MyGoods,
    MyFooter
  },
}
</script>

<style>
  .main{
    padding-top: 45px;
    padding-bottom: 50px;
  }
</style>